#ifndef SOKO_BYTE_ARRAY_H
#define SOKO_BYTE_ARRAY_H

#include <stdint.h>
#include "StringEncoding.h"

namespace soko {


	class ByteArray {

		class ByteArrayRep;

	public:

		explicit ByteArray(int capacity = 0);
		ByteArray(const unsigned char * bytes, int length);
		ByteArray(const std::wstring & string, StringEncoding encoding);
		explicit ByteArray(const ByteArray & byteArray);

		int length() const;
		int capacity() const;
		const unsigned char * bytes() const;
		
		unsigned char & operator[](int index);

		void copyTo(int offset, unsigned char * buffer, int length);

		void append(unsigned char aByte);
		void append(const unsigned char * bytes, int length);
		void append(const ByteArray & byteArray);

		void replace(int location, unsigned char aByte);
		void replace(int location, int length, const unsigned char * bytes, int length);
		void replace(int location, int length, const ByteArray & byteArray);


	private:
		ByteArrayRep * mRep;

	};

}

using soko::ByteArray;

#endif // SOKO_BYTE_ARRAY_H
